import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;


public class Teste {
	public static void main(String[] args) throws IOException {
		renomearArquivos();
		
	}
	
	public static void renomearArquivos(){
		String filePath = "D:/DataSets/DataSet2Splitted/12MapInputs/";
		String[] patitions = new File(filePath).list();
		int count = 0;
	    for (String partition : patitions) {
	    	if (partition.substring(partition.length()-3, partition.length()).equalsIgnoreCase("txt")){
	    		count = Integer.parseInt(partition.substring(4, partition.length()-4));
	    		new File(filePath + partition).renameTo(new File(filePath + "Partition_" + (count-1) + ".txt"));  
	    	}
		}
	}
	
	public static void ordenar() throws IOException {
		File arquivo = new File( "D:/DataSets/DataSet1Splitted/1MapInputs/Ordered/Partition_0.txt" );
		FileReader fr = new FileReader( arquivo );
		BufferedReader br = new BufferedReader( fr );
		String[] st = new String[214230];
		int count = 0;
		while( br.ready() ){
			st[count] = br.readLine();
			count++;
		}
		br.close();
		fr.close();
		
		Arrays.sort(st);
		
		arquivo = new File( "D:/DataSets/DataSet1Splitted/1MapInputs/Ordered/Partition_0ord.txt" );
		FileWriter fw = new FileWriter(arquivo);
		BufferedWriter bw = new BufferedWriter( fw );
		for (int i = 0; i < 214230; i++){
			bw.write(st[i]);
			bw.newLine();
		}
		bw.close();
		fw.close();
	}
}
